package com.example.databinding_demo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.view.View;

import com.example.databinding_demo.databinding.ActivityMainBindingImpl;

public class MainActivity extends AppCompatActivity {

    ActivityMainBindingImpl binding;
    User user;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        user = new User();
        user.setUsername("刘德华");
        user.setPwd(1);
        binding.setUser(user);
        binding.setActivity(this);

    }

    public void onClick(View view){
        int pwd = user.getPwd();
        user.setPwd(pwd+1);
    }
}